﻿#region

using System.Drawing;
using Tank90.Properties;

#endregion

namespace Tank90
{
    public class Bullet : Role
    {
        public Bullet(int x, int y, Directions directions)
        {
            this.x = x;
            this.y = y;
            this.directions = directions;

            dirImage = Resources.enemymissile;
            speed = 10;
        }

        public int power { get; set; }
        public int type { get; set; } //子弹的类型

        public override void Move()
        {
            if (!died && dirImage != null)
            {
                if (directions == Directions.Up)
                {
                    y -= speed;
                }
                if (directions == Directions.Down)
                {
                    y += speed;
                }
                if (directions == Directions.Left)
                {
                    x -= speed;
                }
                if (directions == Directions.Right)
                {
                    x += speed;
                }
            }
        }


        public override void Drawing(Graphics graphics)
        {
            if (dirImage != null)
            {
                graphics.DrawImage(dirImage, new Point(x, y));
            }
        }

        //public override void Death()
        //{
        //    this.x = 1000;
        //    this.y = 1000;
        //}

        public override Rectangle GetRectangle()
        {
            return new Rectangle(x, y, 20, 20);
        }

        public bool IsBeyondEdge()
        {
            return died = x < 0 || x > 640 || y < 0 || y > 640;
        }
    }
}